﻿using System;
using System.Collections.Generic;

namespace ToDoList.Logic
{
    /// <summary>
    /// 初始化
    /// </summary>
    public class TestData
    {
        public static List<User> Users = new List<User>();
        public static List<DetailedList> DetailedLists = new List<DetailedList>();
        public static List<WaitToDoList> WaitToDoLists = new List<WaitToDoList>();

        public TestData()
        {
            //初始化一个用户
            var InitUser = new User
            {
                UserId = 1,
                UserName = "程昱",
                PassWord = "123456"
            };
            //初始化一个清单
            var InitializationList = new DetailedList()
            {
                ListId = 1,
                CreationTime = DateTime.Now,
                ListName = "实验室学习"
            };
            //初始化事项
            List<WaitToDoList> InitializationItems = new List<WaitToDoList>()
            {
                new WaitToDoList
                {
                    EventID = 1,
                    CreationTime = DateTime.Now,
                    CreationUser = 1,
                    Content = "中午去打酱油",
                    State = false,
                    Remarks = "东边菜市酱油比西边菜市好",
                    OverdueEvent = DateTime.Parse("2015-10-11 10:50:20")
                },
                new WaitToDoList
                 {
                    EventID = 2,
                    CreationTime = DateTime.Now,
                    CreationUser = 1,
                    Content = "晚上去耍朋友",
                    State = false,
                    Remarks = "现女友比前女友漂亮",
                    OverdueEvent = DateTime.Parse("2017-10-11 10:50:20")
                }
            };
            //将事项添加在清单中
            InitializationList.WaitToDoLists = new List<WaitToDoList>();
            InitializationList.WaitToDoLists.AddRange(InitializationItems);
            //添加一个清单在用户中
            InitUser.DetailedLists = new List<DetailedList>();
            InitUser.DetailedLists.Add(InitializationList);
            InitializationList.UserId = InitUser.UserId;
            //给用户添加事项
            InitUser.WaitToDoLists = new List<WaitToDoList>();
            InitUser.WaitToDoLists.AddRange(InitializationItems);
            //将初始化的值赋值在static中
            Users.Add(InitUser);
            DetailedLists.Add(InitializationList);
            WaitToDoLists.AddRange(InitializationItems);
        }
    }
}
